package cn.school;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import cn.school.util.DBUtil;

public class GetStuNum {

	public static void main(String[] args) {
		String sql = "select count(stuno)as t from s_student";
		try (Connection con = DBUtil.getConnection();
				PreparedStatement ps = con.prepareStatement(sql);
				ResultSet rs = ps.executeQuery();) {
			if (rs.next()) {
				int count = rs.getInt(1);// 用位置
				System.out.printf("学生总数为%d人", count);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
